<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/jquery-3.6.3.min.js"></script>
		<script>
			$(function(){
				$("form [data-reg]").each(function(){
					var t=$(this);
					t.blur(function(){
						let pattern=eval(t.attr("data-reg"));
						let v=t.val();
						if(pattern.test(v)){
							t.next().text(t.attr("data-ok"));
							return true;
						}
						t.next().text(t.attr("data-error"));
						return false;
					});
				});
				$("#form").submit(function(){
					var f=true;
					$("form [data-reg]").each(function(){
						console.log(this);
						f=f&$(this).triggerHandler("blur");
						console.log(f);
						return true;
					});
					//alert(f);
				    return f>0;
				});
			});
		</script>
	</head>
	<body>
		<h2>手机中注册</h2>
		<form action="2.html" id="form">
			<p>
				<input type="text" id="mobile" name="mobile" autocomplete="off" placeholder="请输入您的常用手机号" param="请输入您的常用手机号" data-reg="/^1[3-9]\d{9}$/" data-ok="√" data-error="请输入您的手机号" class="reg-input" id="mobile" maxlength="11" /><span ></span>
			</p>
			<p>
				<input type="text" data-reg="/^\d{6}$/" data-ok="√" data-error="请输入手机上收到的验证码,5分钟有效" name="yanzhengma" maxlength="6" placeholder="6位验证码" /><span ></span>
			</p>
			<p>
				<input type="password" data-reg="/^\S{8,30}$/" data-ok="√" data-error="请输入8-30个字符" name="pass" maxlength="30" placeholder="密码长度是8-30" /><span ></span>
			</p>
			<p>
				<input type="text" data-reg="/^[\u4e00-\u9fa5]{0,200}$/" data-ok="√" data-error="请输入正确地址" name="dizhi" maxlength="200" placeholder="地址" /><span ></span>
			</p>
			<!-- <div>
				是否愿意接收我们的电子邮件:<input type="checkbox" id="accpetEmail" name="accpetEmail" value="on"/>
				<div style="display:none;">
					你的邮件地址:<input type="email" disabled required placeholder="常用邮件地址"/><span></span>
				</div>
			</div> -->
			<p>
				<input type="submit" value="注册"/>
			</p>
		</form>
	</body>
</html>